#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int LuckyNum(vector<int>& a, int n, int pos, int sum, int muli)
{
    int count = 0;
    for (int i = pos; i < n; i++) {
        sum += a[i];
        muli *= a[i];
        if (sum > muli) {
            count += 1 + LuckyNum(a, n, i + 1, sum, muli);
        }
        else if (a[i] == 1) {
            count += LuckyNum(a, n, i + 1, sum, muli);
        }
        else {
            break;
        }
        sum -= a[i];
        muli /= a[i];
        while (i < n - 1 && a[i] == a[i + 1]) i++;
    }

    return count;
}

int main()
{
    int n;
    while (cin >> n) {
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        sort(a.begin(), a.end());
        cout << LuckyNum(a, n, 0, 0, 1) << endl;
    }
    return 0;
}